<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="pragma" content="no-cache">  
<meta http-equiv="cache-control" content="no-cache">  
<meta http-equiv="expires" content="0">   
<title>无标题文档</title>
<link href="../Public/css/reset.css" rel="stylesheet" type="text/css" />
<link href="../Public/css/system.css" rel="stylesheet" type="text/css" />
<link href="../Public/css/table_form.css" rel="stylesheet" type="text/css" />
<link href="/statics/css/dialog.css" rel="stylesheet" type="text/css" />
<style>
table {border-top:1px solid #ccc;border-left:1px solid #ccc;font-size:16px;}
th, td {width:80px;border-right:1px solid #ccc;border-bottom:1px solid #ccc;text-align:center; min-width:150px;}
th {width:120px;font-size:20px;}
td {height:25px;}
table input[type="text"] {width:92%;border:0 none;text-align:center;}
table .bdr-btm-none{width:15px;border-bottom:none;}
.font18 {font-size:18px;}
.color-green {color:#008000;}
.color-red {color:#f00;}
.color-cyan {color:#0cf;}
.bg-yellow {background-color:#ff0;}
td,input{ font-size:16px;}
select { width:180px; text-align:center; font-size:16px; color:#060;}
</style>
<script language="javascript" type="text/javascript" src="/admin/Tpl/public/js/jquery-1.4.2.min.js"></script>
<script>
var size_change_data = <?php echo json_encode($size_change_data);?>;
var size_type_data = <?php echo json_encode($size_type_data);?>;
function sizeDataChange(obj,size_type,size_name_id){
	
	 var s_c_d = size_change_data[size_name_id];
	 var value = parseFloat(obj.value).toFixed(0);
     var size = 0;
	 var zuixiaozhi = 0;
	 var zuidazhi = 0;
	 var chaoxian = false;

	 var difference = 10000; //差值
	 for(var key in s_c_d){
		 if(s_c_d[key] > 1000){
		    continue;
		 }
		 var val = parseFloat(key);
/*		 //加值规则  //裤子
		 var val_start = val - 1 , val_end = val + 2;
		 if(size_type == 3){ var val_start = val - 2 , val_end = val + 1; }
		 //匹配出尺码
		 if(value > (val_start-0.01) && value < (val_end+0.01)){
			 size = s_c_d[key]; 
		 }*/
		 //取最接近的数据
		 var diff = Math.abs(value - val);
		 if(diff < difference){
			 difference = diff;
		     size = s_c_d[key];
		 }
		 
	 }
	 $('#chima_'+size_type).val(size); 
	 sizeChange(size_type,size);
    if(size_type==11){
        if(value>=92&&value<96){
            $('#chima_'+size_type).val(36);
            sizeChange(size_type,36);
        }
        if(value>=96&&value<102){
            $('#chima_'+size_type).val(38);
            sizeChange(size_type,38);
        }
        if(value>=102&&value<106){
            $('#chima_'+size_type).val(40);
            sizeChange(size_type,40);
        }
        if(value>=106&&value<112){
            $('#chima_'+size_type).val(42);
            sizeChange(size_type,42);
        }
        if(value>=112&&value<118){
            $('#chima_'+size_type).val(44);
            sizeChange(size_type,44);
        }
        if(value>=118&&value<122){
            $('#chima_'+size_type).val(46);
            sizeChange(size_type,46);
        }
    }

}
function sizeChangeSK(size_type,obj){
	 var size = parseInt(obj.value);
     sizeChange(size_type,size)
}
function sizeChange(size_type,size){
	 if(size == 0){$('.size_show_'+size_type).html('');return;}
	 //尺码表
	 var size_data = size_type_data[size_type][size];
	 for(var key in size_data){
         $('#size_show_'+size_data[key]['size_name_id']).html(size_data[key]['size_cm']);
	 }	
}
function sizeDefault(){
	 var s_c_d = size_change_data;
	 for(var key in s_c_d){
		  $('#cysize_'+key).keyup();
	 }
}
function chimaDefault(){
	$('.chima').each(function(){
	    if( $(this).val() != 0 ){ $(this).change();}
	}); 
}
var keyCode = 0
document.onkeydown=function(event){
    var e = event || window.event || arguments.callee.caller.arguments[0];
    keyCode = 0
    //alert(e.keyCode);
	if(e && e.keyCode==9){ // 按 tab 
	     keyCode = 9; 
		 return false;
	}
};
function keyTab(obj, classname,size_type){
    if(keyCode == 9){
		var index = $("."+classname+'_'+size_type).index(obj);
		var length = $("."+classname+'_'+size_type).length;
		index += 1;
		if(classname == "cy" && index >= length){
			classname = "mtm";
			index = 0;		
		}
	    $("."+classname+'_'+size_type).eq(index).focus().select();
		
	}
}
function yidong(size_type, type){
	$('.size_name_id_'+size_type).each(function(){
		var size_name_id = $(this).val();
		if(type == 1){
		    $('#mtmsize_'+size_name_id).val($('#cysize_'+size_name_id).val());
		}
		if(type == 2){
		    $('#cysize_'+size_name_id).val($('#mtmsize_'+size_name_id).val());
		}
		sizeDefault();
	}); 
}
$(function(){
   <?php if(empty($size_measure) || $is_xcm){ ?>sizeDefault();<?php }else{ ?> chimaDefault();<?php }; ?> 	
      order_list_by_measure(<?php echo $measure['user_id']?>,<?php echo $order['order_id'];?>);
})

function order_pro_tips(obj,id){
    var action_notice = window.prompt("请在下面小框内输入暂停原因!",""); 
	if(action_notice==null){
	   return false;
	}
	$.ajax({
		type: 'POST',
		url: "<?php echo U('order/order_pro');?>&order_id="+id,
		data: {"round":Math.random(),'order_status':'<?php echo OrderModel::ORDER_PAUSE;?>','action_notice':action_notice},
		async:false,
		success: function(msg) {
			 if(msg != '1'){
				 alert(msg)
			 }else{
				$('#order_pro_tips').html('此订单已暂停');
			 }
		}
   });  
}

function order_list_by_measure(user_id,order_id){
    $.ajax({
        type:'POST',
        url:"<?php echo U('order/order_list_by_measure');?>&user_id="+user_id+"&order_id="+order_id,
        success:function(msg){
            if(msg){
                $('#table_2').append(msg);
            }
        }
    });
}
</script>
</head>
<body>
<form action="" method="post" autocomplete="off">        
<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td colspan="11" style="height:70px;font-size:25px;"><?php echo $order_sn.' &nbsp;&nbsp; 订单id:'.$order_id.'-'.$order_item_id;?>&nbsp;&nbsp;|&nbsp;&nbsp;货号：<?php echo $order['product_sn'];?>|<font color="red">商品名称：<?php echo $orderfigure['product_name']?></font></td>
    <td id="order_pro_tips"><script src="<?php echo U('order/order_pro_show',array('order_id'=>$order_id));?>"></script></td>
  </tr>
    <tr>
    <td colspan="4"></td>
    <td colspan="8" id="order_pro_tips" style="text-align:left;">
        <div class="content-menu ib-a blue line-x">
        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href='javascript:;' class="on" onclick="set_table_display(this,1)"><em>相关订单</em></a> / <a href='javascript:;' onclick="set_table_display(this,2)"><em>修改记录</em></a>  </div>
        </div>
    </td>
  </tr>
    <tr>
    <th colspan="2">客户名</th>
    <td colspan="2">
	<?php echo $measure['measure_name']?>
    <?php 
	    echo '<br />';
	    if($measure['m_status'] == 5){
		    $sizename = array(
				'1' => 'Jacket Size',
				'2'   => 'Vest Size',
				'3'   => 'Pant Size',
				'4'  => 'Shirt Size',
				'5'   => 'Coat Size',		    
			);
			foreach(unserialize($measure['measure_data']) as $mskey=>$msval):
			    echo $sizename[$mskey].':'.$msval.' '; 
			endforeach;
        }
    ?>
    </td>
    <td colspan="8" rowspan="100" style="text-align:left; vertical-align:top;">

          <?php 
			foreach($eidt_array_data as $key => $val){  
		  ?> 
          <table class="table_1" width="120px" border="0" cellspacing="0" cellpadding="0" style="border:0; float:left;display:none">
			   <?php 
                    foreach($val as $k => $v){  
               ?>          
               <tr><td>
               <?php if($v['name'] == 'timeData'){ ?>
                   <?php echo $v['value'];?>
               <?php }else if($v['name'] == 'button'){ ?>
				   <input type="button" style="width:50px; border:1px solid #FFF; background-color:#FFF; color:#FFF; cursor:pointer;"  value="&lt;=">
               <?php
			   }else{ 
			   ?>
			      <input  style="color:red; width:50px;"  type="text" value="<?php if(floatval($v['value'])>0){ echo "+";}?><?php echo $v['value'];?>">
               <?php
			   }
			   ?>
               
               </td></tr>
               <?php  }  ?>
          </table>
          &nbsp;
          <?php  }  ?>

        <table id="table_2" style="">
            <tr><td>订单号</td><td>收货人</td><td>商品名称</td><td>身形名称</td><td>订单状态</td><td>发货时间</td></tr>
        </table>
   </td>
  </tr>
  <tr>
    <td style="width:150px;">身高</td>
    <td style="width:150px;"><input type="text" value="<?php echo $measure['height']?>"></td>
    <td style="width:150px;">肩</td>
    <td style="width:150px;" ><input type="text" value="<?php if($measure['shoulder']==1){echo "方肩";}elseif($measure['shoulder']==2){echo "介于高和正常";}elseif($measure['shoulder']==3){echo "正常";}elseif($measure['shoulder']==4){echo "介于正常和溜肩";}elseif($measure['shoulder']==5){echo "溜肩";}else{echo '正常';}?>"></td>
    
  </tr>
  <tr>
    <td>体重</td>
    <td><input type="text" value="<?php echo $measure['weight']?>"></td>
    <td>胸</td>
    <td><input type="text" value="<?php  if($measure['chest_type']==1){echo "胸肌发达";}elseif($measure['chest_type']==2){echo "介于发达和正常";}elseif($measure['chest_type']==3){echo "正常";}elseif($measure['chest_type']==4){echo "介于正常和肥胖";}elseif($measure['chest_type']==5){echo "厚胸";}else{echo '正常';} ?>"></td>
    
  </tr>
  <tr>
    <td>年龄</td>
    <td><input type="text" value="<?php echo $measure['age']?>"></td>
    <td>肚</td>
    <td><input type="text" value="<?php  if($measure['stomach_type']==1){echo "平肚";}elseif($measure['stomach_type']==2){echo "介于平腹和微凸";}elseif($measure['stomach_type']==3){echo "正常";}elseif($measure['stomach_type']==4){echo "介于微凸和凸腹";}elseif($measure['stomach_type']==5){echo "凸肚";}else{echo '正常';}?>"></td>
    
  </tr>  
  <tr>
    <td></td>
    <td></td>
    <td>背</td>
    <td><input type="text" value="<?php if($measure['posture']['type']==1){echo "平背";}elseif($measure['posture']['type']==2){echo "微挺";}elseif($measure['posture']['type']==3){echo "正常";}elseif($measure['posture']['type']==4){echo "微驼";}elseif($measure['posture']['type']==5){echo "驼背";}else{echo '正常';}?>"></td>
    
  </tr> 
  
    <?php foreach($size_type as $key=>$val):?>
        <tr>
        <td colspan="4"> <span style="font-size:12px;"><?php if($val['time']>0) echo "(".date('Y-m-d',$val['time']).")"; ?></span> <span style="font-weight:bold;"><?php echo $val['type_name']; ?></span></td>
        </tr>
        <tr>
        <td>版型</td>
        <td>
        <select name="size_measure[<?php echo $val['id']; ?>][model]">
            <option value="合体" <?php if($val['model_val']==1 || $val['model']=='合体'){ echo 'selected="selected"'; }; ?> >合体</option>
            <option value="修身" <?php if($val['model_val']==2 || $val['model']=='修身'){ echo 'selected="selected"'; }; ?> >修身</option>
        </select>
        </td>
        <td>尺码</td>
        <td>
            <select name="size_measure[<?php echo $val['id']; ?>][chima]" onchange="sizeChangeSK(<?php echo $val['id']; ?>,this);" id="chima_<?php echo $val['id']; ?>" class="chima" style="color:#060; text-align:center;" >
                <option value="0"></option>
                <?php if($val['id']==11){?>
                    <?php for($i=36;$i<=46;$i+=2):?>
                        <option value="<?php echo $i; ?>" <?php if( $val['chima'] == $i ){ echo 'selected="selected"';  }; ?> ><?php echo C('sweater_szie_value')[$i]; ?></option>
                    <?php endfor;?>
                <?php }else{?>
                    <?php for($i=24;$i<=74;$i+=2):?>
                    <option value="<?php echo $i; ?>" <?php if( $val['chima'] == $i ){ echo 'selected="selected"';  }; ?> ><?php echo $i; ?></option>
                    <?php endfor;?>
                    <?php if($val['id'] == 3):?>
                    <?php for($i=24;$i<=74;$i+=2):?>
                    <option value="<?php echo (1000+$i); ?>" <?php if( $val['chima'] == (1000+$i) ){ echo 'selected="selected"';  }; ?> ><?php echo strval($i)."(小脚裤)"; ?></option>
                    <?php endfor;?>
                    <?php endif;?>
                <?php }?>
            </select>
        </td>
        </tr>
        <tr>
        <td></td>
        <td>成衣尺寸</td>
        <td>
        <input type="button" value="=>" onclick="yidong(<?php echo $val['id']; ?>,1);" style="width:50px; border:1px solid #09F; background-color:#09F; color:#FFF; cursor:pointer;" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
        <input type="button" value="<=" onclick="yidong(<?php echo $val['id']; ?>,2);" style="width:50px; border:1px solid #09F; background-color:#09F; color:#FFF; cursor:pointer;" />
        </td>
        <td>MTM尺寸</td>
        </tr>
		<?php foreach($val['size_name'] as $k=>$v):?>
            <?php if($v['more_type']==1) continue; ?>
            <input type="hidden" value="<?php echo $v['id']; ?>" class="size_name_id_<?php echo $val['id']; ?>" />
            <tr>
            <td <?php if($v['is_change']==1){echo 'style="background-color:#F00;"';}; ?> ><?php echo $v['size_name']; ?></td>
            <td <?php if($v['is_change']==1){echo 'style="background-color:#F00;"';}; ?> >
                 <input type="text"  name="size_measure[<?php echo $val['id']; ?>][cy][<?php echo $v['id']; ?>]" value="<?php echo $v['cysize']; ?>" 
				 <?php if($v['is_change']==1){echo 'onkeyup="sizeDataChange(this,'.$val['id'].','.$v['id'].');keyTab(this,\'cy\',\''.$val['id'].'\');"';}; ?> id="cysize_<?php echo $v['id']; ?>" class="cy_<?php echo $val['id']; ?>" onkeyup="keyTab(this,'cy','<?php echo $val['id']; ?>');" style="color:#F00;" />
            </td>
            <td id="size_show_<?php echo $v['id']; ?>" class="size_show_<?php echo $val['id']; ?>" style="background-color:#FF0;"></td>
            <td><input type="text"  name="size_measure[<?php echo $val['id']; ?>][mtm][<?php echo $v['id']; ?>]" value="<?php echo $v['mtmsize']; ?>" id="mtmsize_<?php echo $v['id']; ?>"   class="mtm_<?php echo $val['id']; ?>"  onkeyup="keyTab(this,'mtm','<?php echo $val['id']; ?>');" style="color:#F00;"   /></td>

            </tr>
        <?php endforeach;?>
                 
        <tr>
        <td colspan="4"></td>
        </tr>
        <?php $i=0; foreach($val['mtmselect'] as $mtmadd_k => $mtmadd_v):?>
            <tr>
            <td></td>
            <td><?php if($i==0){echo "MTM变更";}?></td>
            <td>
                <select name="mtmadd_k[<?php echo $val['id']; ?>][<?php echo $i; ?>]">
                    <option value=""></option>
                    <?php foreach($val['size_name'] as $k=>$v):?>
                    <?php if($v['more_type']==0) continue; ?>
                        <option value="<?php echo $v['id']; ?>" <?php if($v['id'] == $mtmadd_k) echo 'selected="selected"'; ?> ><?php echo $v['size_name']; ?></option>
                    <?php endforeach;?>    
                </select>       
            </td>
            <td><input type="text"  name="mtmadd_v[<?php echo $val['id']; ?>][<?php echo $i; ?>]" value="<?php echo $mtmadd_v; ?>" style="color:#09F;" class="mtm_<?php echo $val['id']; ?>" onkeyup="keyTab(this,'mtm','<?php echo $val['id']; ?>');"  /></td>

            </tr>
        <?php $i++;endforeach;?>         
        <?php for($i=count($val['mtmselect']);$i<10;$i++):?>
            <tr>
            <td></td>
            <td><?php if($i==0){echo "MTM变更";}?></td>
            <td>
                <select name="mtmadd_k[<?php echo $val['id']; ?>][<?php echo $i; ?>]">
                    <option value=""></option>
                    <?php foreach($val['size_name'] as $k=>$v):?>
                    <?php if($v['more_type']==0) continue; ?>
                        <option value="<?php echo $v['id']; ?>"><?php echo $v['size_name']; ?></option>
                    <?php endforeach;?>    
                </select>       
            </td>
            <td><input type="text"  name="mtmadd_v[<?php echo $val['id']; ?>][<?php echo $i; ?>]" value="" style="color:#09F;"  class="mtm_<?php echo $val['id']; ?>" onkeyup="keyTab(this,'mtm','<?php echo $val['id']; ?>');" /></td>

            </tr>
        <?php endfor;?>          
    <?php endforeach;?>
</table>
<table width="100%" border="0">
  <tr>
    <td align="center" style="text-align:left; padding-left:300px;">
      <input type="hidden" name="order_item_id" value="<?php echo $order['id'];?>" />
      <input type="hidden" name="measure_id" value="<?php echo $order['measure_id'];?>" />
      <input type="hidden" name="product_model_id" value="<?php echo $product_model_id;?>" />
      
      <input type="submit" name="dosubmit" value="保存" style="width:150px; height:40px; border:1px solid #09F; background-color:#09F; color:#FFF; cursor:pointer;" />
    </td>
  </tr>
</table>
</form>
</body>
    <script>
        function set_table_display(obj,number){
            if(number == 2){
                $('.table_1').css("display","block");
                $('#table_2').css("display","none");
                $(".on").removeClass('on');
                $(obj).addClass('on');
            }else if(number == 1){
                $('.table_1').css("display","none");
                $("#table_2").css("display","block");
                 $(".on").removeClass('on');
                  $(obj).addClass('on');
            }
        }
        </script>
</html>

